#include "mymusic.h"
#include "ui_mymusic.h"
#include <QDebug>
#include <QGraphicsDropShadowEffect>

MyMusic::MyMusic(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::MyMusic)
{
    ui->setupUi(this);

    initUI();
}

MyMusic::~MyMusic()
{
    delete ui;
}

void MyMusic::initUI()
{
    // 设置⽆边框窗⼝，即窗⼝将来⽆标题栏
    this->setWindowFlag(Qt::FramelessWindowHint);
    // 设置窗⼝背景透明
    this->setAttribute(Qt::WA_TranslucentBackground);
    // 给窗⼝设置阴影效果
    QGraphicsDropShadowEffect* shadowEffect = new
    QGraphicsDropShadowEffect(this); shadowEffect->setOffset(0,0); // 设置阴影偏移
    shadowEffect->setColor("#000000"); // 设置阴影颜⾊：⿊⾊
    shadowEffect->setBlurRadius(10); // 设置阴影的模糊半径
    this->setGraphicsEffect(shadowEffect);
}

void MyMusic::mousePressEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton){
        dragPosition = event->globalPos() - geometry().topLeft();
    }
}

void MyMusic::mouseMoveEvent(QMouseEvent *event)
{
    if(event->buttons() == Qt::LeftButton)
     {
        // 根据⿏标移动更新窗⼝位置
        move(event->globalPos() - dragPosition);
        //qDebug() << "move";
     }
}


void MyMusic::on_quit_clicked()
{
    close();
}
